package com.goodfather.textbook.youdao.pad.util;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.goodfather.textbook.youdao.pad.R;


public class PayDialog extends DialogBaseV1 {

    TextView mBookName;
    TextView mValidity;
    TextView mAmount;
    Button mBtnCancel;
    Button mBtnConfirm;
    private PayDialogListener mListener;


    public void show(Context context, PayDialogListener listener) {
        if (mDialog == null) {
            View view = LayoutInflater.from(context).inflate(R.layout.dialog_pay, null);
            mListener = listener;
            super.create(context, view);
        }
        mDialog.show();
        isShowing = true;
    }


    @Override
    public void initView(View view) {
        setWindowStyle(true, Gravity.CENTER, false);
        mBookName =view.findViewById(R.id.tv_book_name);
        mValidity =view.findViewById(R.id.tv_validity);
        mAmount =view.findViewById(R.id.tv_amount);
        mBtnCancel =view.findViewById(R.id.btn_cancel);
        mBtnConfirm =view.findViewById(R.id.btn_pay);
        initListener();
    }

    @Override
    public void initData() {

    }

    void initListener() {
        if (mListener != null) {
            mListener.onGetNameView(mBookName);
            mListener.onGetValidView(mValidity);
            mListener.onGetAmountView(mAmount);
            mListener.onGetConfirmBtn(mBtnConfirm);
            mListener.onGetCancelBtn(mBtnCancel);
        }

        if (TextUtils.isEmpty(mBtnConfirm.getText())) {
            mBtnConfirm.setVisibility(View.GONE);
        }
        if (TextUtils.isEmpty(mBtnCancel.getText())) {
            mBtnCancel.setVisibility(View.GONE);
        }
    }

    public interface PayDialogListener {
        void onGetNameView(TextView mBookName);
        void onGetValidView(TextView mValidity);
        void onGetAmountView(TextView mAmount);
        void onGetConfirmBtn(TextView confirm);
        void onGetCancelBtn(TextView cancel);

    }
}
